﻿// // ******************************************************************
// //       /\ /|       @file       AiConfigService.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2025-02-01 16:02
// //    *(__\_\        @Copyright  Copyright (c) , 2025-01-29 21:01 Await
// // ******************************************************************

using AutomaticSubtitles.Contracts.Dto;
using AutomaticSubtitles.Contracts.Vo;
using AutomaticSubtitles.Service.Application.AiConfig.Commands;
using AutomaticSubtitles.Service.Application.AiConfig.Queries;
using AutomaticSubtitles.Service.Application.Cahce.Queries;

namespace AutomaticSubtitles.Service.Services;

public class AiConfigService : BaseService<AiConfigService>
{
    [EndpointDescription("添加Ai配置")]
    [EndpointName("添加Ai配置")]
    [EndpointSummary("添加Ai配置")]
    [Authorize]
    public async Task<ResponseModel<int>> AddAsync(AiConfigVo data)
    {
        var command = new AddAiConfigCommand(data);
        await PublishAsync(command);
        return command.Result.CreateResultAdd_Msg();
    }

    [EndpointDescription("更新Ai配置")]
    [EndpointName("更新Ai配置")]
    [EndpointSummary("更新Ai配置")]
    [Authorize]
    public async Task<ResponseModel<int>> UpdateAsync(AiConfigVo data)
    {
        var command = new UpdateAiConfigCommand(data);
        await PublishAsync(command);
        return command.Result.CreateResultUpdate_Msg();
    }

    [EndpointDescription("删除Ai配置")]
    [EndpointName("删除Ai配置")]
    [EndpointSummary("删除Ai配置")]
    [Authorize]
    public async Task<ResponseModel<int>> DeleteAsync(string id)
    {
        var command = new DeleteAiConfigCommand(id);
        await PublishAsync(command);
        return command.Result.CreateResultDelete_Msg();
    }

    [EndpointDescription("获取Ai表格")]
    [EndpointName("获取Ai表格")]
    [EndpointSummary("获取Ai表格")]
    [Authorize]
    public async Task<ResponseModel<IReadOnlyList<AiConfigDto>>> GetListAsync()
    {
        var command = new GetListAiConfigQuery();
        await PublishAsync(command);
        return command.Result.CreateResult();
    }
}